﻿using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace IntoNails.Infrastructure.Extensions
{
    public static class StreamExtensions
    {
        public static void Serialize<T>(this T data, Stream saveStream)
        {
            var formatter = new BinaryFormatter();
            formatter.Serialize(saveStream, data);
        }

        public static T Deserialize<T>(this Stream loadStream)
        {
            var formatter = new BinaryFormatter();
            return (T) formatter.Deserialize(loadStream);
        }
    }
}
